package com.lib.controller.admin;

import com.lib.pojo.DTO.LoginDTO;
import com.lib.pojo.entity.AdminUser;
import com.lib.pojo.entity.LoginInfo;
import com.lib.pojo.entity.Result;
import com.lib.service.LoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.coyote.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/admin/login")
@Tag(name = "管理员登录接口")
@CrossOrigin(origins = "*")
public class LoginController {
    @Autowired
    private LoginService loginService;
    //1:管理员登录
    @PostMapping
    @Operation(summary = "管理员登录")
    public Result<LoginInfo> login(@RequestBody AdminUser adminUser){
        LoginInfo loginInfo = loginService.login(adminUser);
        if (loginInfo != null){
            return Result.success(loginInfo);
        }
        return Result.error("用户名或密码错误");
    }
}
